package ca.etsmtl.log720.tp3.dao;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class InfractionDAOImpl implements InfractionDAO {

	 @Autowired
	 private SessionFactory sessionFactory;
	
	
	public void addInfraction(Infraction infraction) {
		sessionFactory.getCurrentSession().save(infraction);

	}

	
	@SuppressWarnings("unchecked")
	public List<Infraction> listInfraction() {
		return sessionFactory.getCurrentSession()
				.createQuery("from infraction")
                .list();
	}

}
